﻿Imports System.IO
Imports System.Security.Permissions

Public Class Encargado

    Dim nombre As String

    Public Property _nombre
        Get
            Return nombre
        End Get
        Set(ByVal value)
            nombre = value
        End Set
    End Property

    Private Sub Encargado_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        lbl_bienvenido.Text += nombre
        Dim strStreamW3 As Stream = Nothing

        If File.Exists("TELEFONOS.txt") Then
            'Abrimos el archivo
            txt_telefonos.LoadFile("TELEFONOS.txt", RichTextBoxStreamType.PlainText)
        Else
            'lo creamos
            strStreamW3 = File.Create("TELEFONOS.txt")
        End If

        If File.Exists("NOTAS.txt") Then
            'Abrimos el archivo
            RichTextBox1.LoadFile("NOTAS.txt", RichTextBoxStreamType.PlainText)
        Else
            'lo creamos
            strStreamW3 = File.Create("NOTAS.txt")
        End If
    End Sub

    'GUARDAR TELEFONOS
    Private Sub btn_guardar_tel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_guardar_tel.Click
        Dim sRenglon As String = Nothing
        Dim strStreamW As Stream = Nothing
        Dim strStreamWriter As StreamWriter = Nothing
        Dim ContenidoArchivo As String = Nothing
        Dim access As FileIOPermissionAccess

        ' Donde guardamos la ruta de los archivos que vamos a estar utilizando ..
        Dim PathArchivo As String

        Try
            'Se determina el nombre del archivo
            PathArchivo = "TELEFONOS.txt"
            access = System.Security.Permissions.FileIOPermissionAccess.AllAccess

            'verificamos si existe el archivo
            If File.Exists(PathArchivo) Then
                'Abrimos el archivo
                strStreamW = File.Open(PathArchivo, FileMode.Truncate)
            Else
                'lo creamos
                strStreamW = File.Create(PathArchivo)
            End If

            'tipo de codificacion para escritura
            strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.Default)

            'escribimos en el archivo
            strStreamWriter.WriteLine(Me.txt_telefonos.Text, False, False)

            'cerramos
            strStreamWriter.Close()
        Catch ex As Exception
            MsgBox("Error al Guardar la informacion en el archivo TELEFONOS." & ex.ToString, MsgBoxStyle.Critical, Application.ProductName)
            'cerramos
            strStreamWriter.Close()
        End Try
    End Sub

    'GUARDAR NOTAS
    Private Sub btn_guardar_nota_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_guardar_nota.Click
        Dim sRenglon2 As String = Nothing
        Dim strStreamW2 As Stream = Nothing
        Dim strStreamWriter2 As StreamWriter = Nothing
        Dim ContenidoArchivo2 As String = Nothing
        Dim access2 As FileIOPermissionAccess

        ' Donde guardamos la ruta de los archivos que vamos a estar utilizando ..
        Dim PathArchivo2 As String

        Try
            'Se determina el nombre del archivo
            PathArchivo2 = "NOTAS.txt"
            access2 = System.Security.Permissions.FileIOPermissionAccess.AllAccess

            'verificamos si existe el archivo
            If File.Exists(PathArchivo2) Then
                'Abrimos el archivo
                strStreamW2 = File.Open(PathArchivo2, FileMode.Truncate)
            Else
                'lo creamos
                strStreamW2 = File.Create(PathArchivo2)
            End If

            'tipo de codificacion para escritura
            strStreamWriter2 = New StreamWriter(strStreamW2, System.Text.Encoding.Default)

            'escribimos en el archivo
            strStreamWriter2.WriteLine(Me.RichTextBox1.Text, False, False)

            'cerramos
            strStreamWriter2.Close()
        Catch ex As Exception
            MsgBox("Error al Guardar la informacion en el archivo NOTAS." & ex.ToString, MsgBoxStyle.Critical, Application.ProductName)
            'cerramos
            strStreamWriter2.Close()
        End Try
    End Sub

    Private Sub EmpleadosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmpleadosToolStripMenuItem.Click
        frm_Empleados.ShowDialog()
    End Sub

    Private Sub TurnosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TurnosToolStripMenuItem.Click
        Turno.Show()
    End Sub

    Private Sub BarriosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BarriosToolStripMenuItem.Click
        Barrio.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_color.Click
        ColorDialog1.ShowDialog()
        RichTextBox1.SelectionColor = ColorDialog1.Color

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_fuente.Click
        FontDialog1.ShowDialog()
        RichTextBox1.SelectionFont = FontDialog1.Font
    End Sub

    Private Sub btn_borrar_nota_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_borrar_nota.Click
        RichTextBox1.Hide()
        btn_borrar_nota.Hide()
        btn_color.Hide()
        btn_fuente.Hide()
        btn_guardar_nota.Hide()
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        RichTextBox1.Show()
        btn_borrar_nota.Show()
        btn_color.Show()
        btn_fuente.Show()
        btn_guardar_nota.Show()
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tele_Utiles.Click
        txt_telefonos.Show()
        btn_ocultar_grilla.Show()
        btn_viñeta.Show()
        btn_guardar_tel.Show()
    End Sub

    Private Sub btn_ocultar_grilla_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ocultar_grilla.Click
        txt_telefonos.Hide()
        btn_ocultar_grilla.Hide()
        btn_viñeta.Hide()
        btn_guardar_tel.Hide()
    End Sub

    Private Sub btn_contraseña_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_contraseña.Click
        Usuario_Contraseña.ShowDialog()
    End Sub

    Private Sub btn_cerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cerrar.Click
        frm_Salir.ShowDialog()
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Principal.Click
        frm_Principal._nombre = nombre
        frm_Principal.Show()
        frm_Principal.lbl_hora.Text = Now.ToLongTimeString
        frm_Principal.lbl_fecha.Text = Now.ToLongDateString
        Me.Hide()
    End Sub

    Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_viñeta.Click
        txt_telefonos.SelectionBullet = True
    End Sub

    Private Sub RegistroEgresoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegistroEgresoToolStripMenuItem.Click
        Planilla_Egreso.ShowDialog()
    End Sub

    Private Sub RegistroIngresoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegistroIngresoToolStripMenuItem.Click
        Planilla_Ingreso.ShowDialog()
    End Sub

    Private Sub AsignacionDeTurnosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AsignacionDeTurnosToolStripMenuItem.Click
        frm_Asignacion_de_Turnos.ShowDialog()
    End Sub

    Private Sub img_busqueda_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles img_busqueda.Click
        Busqueda_Rapida._Nombre = nombre
        Busqueda_Rapida.ShowDialog()
    End Sub

    Private Sub TurnosDeEmpleadosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TurnosDeEmpleadosToolStripMenuItem.Click
        Listado_de_Turnos_de_Empleado.ShowDialog()
    End Sub

    Private Sub HorasMensualesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HorasMensualesToolStripMenuItem.Click
        Listado_de_Horas_Trabajadas_de_Empleado.ShowDialog()
    End Sub

    Private Sub IngresosDiariosPorTurnoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresosDiariosPorTurnoToolStripMenuItem.Click
        Listado_de_Ingresos_diariosxTurnos.ShowDialog()
    End Sub

    Private Sub EgresosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EgresosToolStripMenuItem.Click
        Listado_de_Egresos.ShowDialog()
    End Sub

    Private Sub HorasTrabajadasPorEmpleadoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HorasTrabajadasPorEmpleadoToolStripMenuItem.Click
        EstadisticaHorasTrabajadasEmpleado.ShowDialog()
    End Sub

    Private Sub IngresosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IngresosToolStripMenuItem.Click
        EstadisticaIngresos.ShowDialog()
    End Sub

    Private Sub EgresosToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EgresosToolStripMenuItem1.Click
        EstadisticaEgresos.ShowDialog()
    End Sub

    Private Sub Encargado_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        Dispose()
        frm_Principal.Close()
        frm_Acceso.Close()
    End Sub

    Private Sub lbl_notas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_notas.Click

    End Sub

    Private Sub lbl_dias_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl_dias.Click

    End Sub

    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

    End Sub

    'ABRIR MANUAL PDF
    Private Sub btn_manual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_manual.Click

        Dim loPSI As New ProcessStartInfo
        Dim loProceso As New Process
        loPSI.FileName = "Manual.pdf"
        Try
            loProceso = Process.Start(loPSI)
        Catch Exp As Exception
            MessageBox.Show(Exp.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try

    End Sub

    'ABRIR MANUAL WORD
    Private Sub btn_editar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_editar.Click
        Dim loPSI As New ProcessStartInfo
        Dim loProceso As New Process
        loPSI.FileName = "Manual.docx"
        Try
            loProceso = Process.Start(loPSI)
        Catch Exp As Exception
            MessageBox.Show(Exp.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
    End Sub

    Private Sub img_usuarios_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles img_usuarios.Click
        Me.lbl_pdf.Visible = True
        Me.lbl_word.Visible = True
        Me.btn_manual.Visible = True
        Me.btn_editar.Visible = True
        Me.btn_OcultarUs.Visible = True
    End Sub

    Private Sub btn_OcultarUs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_OcultarUs.Click
        Me.lbl_pdf.Visible = False
        Me.lbl_word.Visible = False
        Me.btn_manual.Visible = False
        Me.btn_editar.Visible = False
        Me.btn_OcultarUs.Visible = False
    End Sub
End Class